package ltd.dujiabao.reserver.domain;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;

import lombok.Data;
import ltd.dujiabao.reserver.util.JsonUtils;

/**
 * @author : DuJiabao
 * @Project : reserver
 * @Time : 2021/11/6 11:49
 * @Desc : 提交表单的请求体里的内容
 * example:
 * formData={"name":"xxx",
 * "mobile":"13798829273",
 * "healthFilePath":"93e57979-9432-4e95-8003-529d77a29283.jpg",
 * "routeFilePath":"be1b8d65-e876-402d-b244-c4ec26982e05.jpg",
 * "isHealthStatement":1,
 * "bookingTimeId":"1058",
 * "code":"cahgp"}
 */
@Data
public class SubmitParam {
    /**
     * 个人姓名
     */
    private String name;

    /**
     * 手机号码
     */
    private String mobile;
    /**
     * 健康码文件名称，需要上传图片之后由响应提供
     */
    private String healthFilePath;
    /**
     * 行程码文件名称，需要上传图片之后由响应提供
     */
    private String routeFilePath;
    /**
     * 是否为健康状态，默认为1即可
     */
    private Integer isHealthStatement = 1;
    /**
     * 预约时间Id，有一个初始值，每天+1
     */
    private String bookingTimeId;
    /**
     * 验证码识别结果
     */
    private String code;

    public static final LocalDate START_DATE = LocalDate.of(2021, 11, 7);

    public static final Integer START_TIME_ID = 1058;

    public SubmitParam(String name, String mobile, String healthFilePath, String routeFilePath, String code) {
        long until = LocalDate.now().until(START_DATE, ChronoUnit.DAYS);
        this.bookingTimeId = String.valueOf(START_TIME_ID + until);
        this.name = name;
        this.mobile = mobile;
        this.healthFilePath = healthFilePath;
        this.routeFilePath = routeFilePath;
        this.code = code;
    }

    @Override
    public String toString() {
        return JsonUtils.bean2Json(this);
    }
}
